﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleSQL
{
    internal class Program
    {

        private static List<Thrain> _threins = new List<Thrain>();
        private static List<Test> _test = new List<Test>();


        static void Main(string[] args)
        {
            var data = new DataClasses1DataContext();

            while (true)
            {
                //var works = data.Work;
                //if (works != null)
                //    foreach (var w in works)
                //    {
                //        if (w.state==1 && _threins.All(t => t._work.id != w.id))
                //        {
                //            Thrain t = new Thrain(w);
                //            _threins.Add(t);
                //            System.Threading.Thread tr = new System.Threading.Thread(t.Start);
                //            tr.Start();
                //        }
                //    }

                var ann = data.Ann;
                if (ann != null)
                    foreach (var w in ann)
                    {
                        if (string.IsNullOrEmpty(w.test) && _test.All(t => t._ann.id != w.id))
                        {

                            Test t = new Test(w);
                            _test.Add(t);
                            System.Threading.Thread tr = new System.Threading.Thread(t.Calc);
                            tr.Start();
                        }
                    }
                
            }
            System.Threading.Thread.Sleep(60000);
        }

     
    }
}
